package mylab.demo.usm.biz.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import mylab.annotation.rds.ColumnComment;
import mylab.annotation.rds.Unique;
import mylab.base.model.entity.LongIdEntity;
import mylab.commons.api.model.Contacts;
import mylab.commons.web.mvc.entity.BaseEntity;

@Getter
@Setter
@ApiModel(description = "应用表")
@TableName(autoResultMap = true)
public class SysApp extends BaseEntity {

    @Unique
    @ColumnComment("客户端身份标识符（应用id）")
    @ApiModelProperty(value = "客户端身份标识符（应用id）", notes = "申请完Oauth应用后，由第三方平台颁发标识")
    @TableField
    private String clientId;

    @ColumnComment("客户端密钥")
    @ApiModelProperty(value = "客户端密钥", notes = "申请完Oauth应用后，由第三方平台颁发")
    @TableField
    private String clientSecret;

    @ColumnComment("应用的站点域名")
    @ApiModelProperty(value = "应用的站点域名")
    @TableField
    private String siteDomain;

    @ColumnComment("登录后的重定向地址")
    @ApiModelProperty(value = "登录后的重定向地址", notes = "用户在确认第三方平台授权（登录）后，第三方平台会重定向到该地址，并携带code等参数")
    @TableField
    private String redirectUri;

    @ColumnComment("logoutRedirectUri")
    @ApiModelProperty(value = "logoutRedirectUri")
    @TableField
    private String logoutRedirectUri;

    @ColumnComment("logo")
    @ApiModelProperty(value = "logo")
    @TableField
    private String logo;

    @ColumnComment("授权范围")
    @ApiModelProperty(value = "授权范围")
    @TableField
    private String scopes;

    @ColumnComment("授权模式")
    @ApiModelProperty(value = "授权模式", notes = "authorization_code:授权码模式  implicit:隐式授权模式  password:密码授权模式 client_credentials:客户端授权模式")
    @TableField
    private String grantTypes;

    @ColumnComment("授权回应类型")
    @ApiModelProperty(value = "授权回应类型", notes = "code token id_token none")
    @TableField
    private String responseTypes;

    @ColumnComment("code过期时间")
    @ApiModelProperty(value = "code过期时间")
    @TableField
    private Long codeExpiresIn;

    @ColumnComment("idToken过期时间")
    @ApiModelProperty(value = "idToken过期时间")
    @TableField
    private Long idTokenExpiresIn;

    @ColumnComment("accessToken过期时间")
    @ApiModelProperty(value = "accessToken过期时间")
    @TableField
    private Long accessTokenExpiresIn;

    @ColumnComment("refreshToken过期时间")
    @ApiModelProperty(value = "refreshToken过期时间")
    @TableField
    private Long refreshTokenExpiresIn;

    @ColumnComment("是否启用自动授权")
    @ApiModelProperty(value = "是否启用自动授权", notes = "自动授权，不需要用户确认界面")
    @TableField
    private Boolean autoApprove;

    @ColumnComment("是否启用授权码-PKCE模式")
    @ApiModelProperty(value = "是否启用授权码-PKCE模式")
    @TableField
    private Boolean enablePkce;

    @ColumnComment("PKCE模式用到的加密方法")
    @ApiModelProperty(value = "PKCE模式用到的加密方法", notes = "先随机生成一个32位长的code_verifier，然后运用hash算法s256加密得到一个code_challenge")
    @TableField
    private String codeChallengeMethod;

    @ColumnComment("负责人")
    @ApiModelProperty(value = "负责人")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Contacts leader;

}
